package spring.cloud.tasks.api.database.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import spring.cloud.tasks.api.database.entity.NameSpaceDto;
import spring.cloud.tasks.api.database.repository.NameSpaceDtoRepository;
import spring.cloud.tasks.api.database.service.NameSpaceDtoService;

import java.util.List;

@Slf4j
@Service
public class NameSpaceDtoServiceImpl implements NameSpaceDtoService {

    private static final int BATCH_NUM = 2000;

    @Autowired
    private NameSpaceDtoRepository nameSpaceDtoRepository;

    @Transactional
    @Override
    public void insert(NameSpaceDto nameSpaceDto) {
        nameSpaceDtoRepository.insert(nameSpaceDto);
    }

    @Override
    public void updateByNameSpace(NameSpaceDto nameSpaceDto) {
        nameSpaceDtoRepository.updateByNameSpace(nameSpaceDto);
    }

    @Transactional
    @Override
    public int deleteByNameSpace(String nameSpace) {
        return nameSpaceDtoRepository.deleteByNameSpace(nameSpace);
    }

    @Override
    public List<NameSpaceDto> selectAll() {
        return nameSpaceDtoRepository.selectAll();
    }


    @Override
    public NameSpaceDto selectByNameSpaceKey(String nameSpace) {
        return nameSpaceDtoRepository.selectByNameSpaceKey(nameSpace);
    }


}
